﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Chitiethoadon.aspx.cs" Inherits="Admin_Chitiethoadon" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>.:Chi tiết hóa đơn:.</title>
    <link href="../CSS/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table cellpadding="4" cellspacing="0" style="width: 100%; text-align: left;">
            <tr>
                <td>Tình trạng</td>
                <td class="sau">
                    <asp:Label ID="lttinhtrang" runat="server"></asp:Label>
                </td>
                <td>
                    <asp:CheckBox ID="ckdagiaohang" runat="server" Text="Đã giao hàng" />
                </td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td width="15%">Mã hóa đơn</td>
                <td class="sau" width="35%">
                    <asp:Label ID="ltmahoadon" runat="server"></asp:Label>
                </td>
                <td width="15%">Ngày mua hàng</td>
                <td class="sau">
                    <asp:Label ID="ltngay" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>Khách hàng</td>
                <td class="sau">
                    <asp:Label ID="ltkhachhang" runat="server"></asp:Label>
                </td>
                <td>Tổng tiền</td>
                <td class="sau">
                    <asp:Label ID="lttongtien" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>Hình thức thanh toán</td>
                <td>
                    <asp:DropDownList ID="drdhinhthucthanhtoan" runat="server" DataSourceID="hinhthucthanhtoan" 
                        DataTextField="tenhinhthucthanhtoan" DataValueField="id_row" Width="90%">
                    </asp:DropDownList>
                </td>
                <td>Hình thức giao hàng</td>
                <td>
                    <asp:DropDownList ID="drdhinhthucgiaohang" runat="server" DataSourceID="hinhthucgiaohang" 
                        DataTextField="tenhinhthucgiaohang" DataValueField="id_row" Width="90%">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="header" colspan="4">Danh sách sản phẩm
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <asp:GridView ID="grvds" runat="server" AutoGenerateColumns="False" 
                                  DataKeyNames="id_hd,id_sp" DataSourceID="chitiethoadon" Width="100%">
                        <Columns>
                            <asp:TemplateField HeaderText="STT">
                                <ItemTemplate><%#Container.DataItemIndex+1 %></ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="3%" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="masp" HeaderText="Mã SP" SortExpression="masp" />
                            <asp:BoundField DataField="tensp" HeaderText="Tên sản phẩm" 
                                SortExpression="tensp" />
                            <asp:BoundField DataField="giamgia" HeaderText="Giảm giá" 
                                SortExpression="giamgia" />
                            <asp:TemplateField HeaderText="Đơn giá">
                                <ItemTemplate>
                                    <asp:Label ID="lbdongia" runat="server" 
                                        Text='<%# Eval("dongia","{0:###,###}") %>'>
                                    </asp:Label>
                                    <asp:Label ID="lbid_sp" runat="server" 
                                        Text='<%# Eval("id_sp") %>' Visible="false">
                                    </asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Số lượng">
                                <ItemTemplate>
                                    <asp:TextBox ID="txtsoluong" runat="server" Text='<%# Eval("soluong") %>' 
                                                 Width="95%" AutoPostBack="True" ontextchanged="txtsoluong_TextChanged">
                                    </asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Thành tiền">
                                <ItemTemplate>
                                    <asp:Label ID="lbthanhtien" runat="server" 
                                        Text='<%# Eval("thanhtien","{0:###,###}") %>'>
                                    </asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <asp:Button ID="btnluu" runat="server" CssClass="ics" onclick="btnluu_Click" 
                                Text="Lưu" />
                    <asp:Button ID="btnhuy" runat="server" CssClass="icc" onclick="btnhuy_Click" 
                                onclientclick="return confirm('Bạn có chắc muốn hủy hóa đơn này?')" 
                                Text="Hủy đơn hàng" />
                </td>
            </tr>
        </table>   
    </div>
    <asp:SqlDataSource ID="chitiethoadon" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT Chitiethoadon.id_hd, Chitiethoadon.id_sp, Chitiethoadon.soluong, Chitiethoadon.dongia, Chitiethoadon.giamgia, Chitiethoadon.thanhtien, SanPham.tensp, SanPham.masp 
                       FROM SanPham INNER JOIN Chitiethoadon ON SanPham.id_row = Chitiethoadon.id_sp
                       where id_hd=@id_hd">
        <SelectParameters>
            <asp:QueryStringParameter Name="id_hd" QueryStringField="id" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="hinhthucthanhtoan" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT [id_row], [tenhinhthucthanhtoan] FROM [Hinhthucthanhtoan]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="hinhthucgiaohang" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT [id_row], [tenhinhthucgiaohang] FROM [Hinhthucgiaohang]">
    </asp:SqlDataSource>
    </form>
</body>
</html>
